#include <stdio.h>

char *strcat(char *s, char *t);

int main(int argc, char *argv[])
{
  char str1[20] = "hello, ";
  char str2[10] = "world";
  char * str3 = strcat(str1, str2);
  printf("%s\n", str1);
  printf("%s\n", str3);
  printf("str1 = %p, str3 = %p\n", str1, str3);

  return 0;
}

char *strcat(char *s, char *t) {
  char *sp = s; // remember the start of pointer to return

  // make s to the end
  while (*s++)
    ;

  // make s point to '\0' and append t to end
  for (--s; (*s++ = *t++);)
    ;

  return sp;
}
